import { Body, Controller, Delete, Get, Param, ParseUUIDPipe, Post, UseInterceptors, ValidationPipe } from "@nestjs/common";
import { PostService } from '../service/Post.Service';
import { PostCreateType } from "src/entity/EntityConfig/types";
import { UpdatePostDto } from "../Dto/Post.Dto";
import { AppInterceptor } from "src/Core/app.Interceptor";
@UseInterceptors( AppInterceptor)
@Controller('/posts')
export class PostController {
    constructor(
        protected PostService: PostService
    ) { }


    @Get('/getData')
    getData() {
        return this.PostService.paginate({ page: 1, limit: 1 })
    }
    @Post('/create')
    async create(
        @Body()
        data: PostCreateType
    ) {
        return this.PostService.create(data)
    }

    @Post('/post')
    async update(
        @Body()
        data:UpdatePostDto,
    ) {
        return this.PostService.updated(data)
    }

    @Delete(':id')
    async delete(@Param('id', new ParseUUIDPipe()) id: string) {
        return this.PostService.delete(id);
    }
}